<?php
$id = $_GET["id"];
$type = $_GET["type"];
$arr = array("*");
$cond = array(
	"id"		=>	$id
	);
$result = $DB->query("select", "messages", $arr, $cond) or die("Error in DB: " . $DB->error());
$row_message = $DB->complete_fetch_array();
		
if ($type == "received"){
	$title = "received";
	$where = "from";
	$user = $row_message[0]["sender"];
	if ($row_message[0]["unread"] == 1) {
		$arr = array(
			"unread" 	=> 	0
			);
		$cond = array(
			"id"		=>	$id
			);
		$result = $DB->query("update", "messages", $arr, $cond) or die("Error in DB: " . $DB->error());
	}
}
else if ($type == "sent"){
	$title = "sent";
	$where = "to";
	$user = $row_message[0]["receiver"];
}
else if ($type == "notes"){
	$title = "saved";
	$where = "to";
	$user = $row_message[0]["receiver"];
}
		
$date = date('Y-m-d, H:i', $row_message[0]["time"]);
$subject = $row_message[0]["subject"];
$content = $row_message[0]["text"];
include("/../styles/html/home/messages/view_mes.php");
?>